<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
</head>
<body>
    <div id="app-28">
        <div style="width: 100%; height: 20px; background: #00BFFF;">
            <router-link to="/index">首页</router-link>
            <router-link to="/index/t2">首页-t2</router-link>
            <router-link to="/index/t3">首页-t3</router-link>
            <router-view></router-view>
        </div>
    </div>

    <script type="text/javascript">
        <!-- vue 的路由旨在为单页面应用开发提供便携 -->
        // 1. 定义链接跳转的模板（组件）
        const t1 = {
            template: `<div style="width: 400px; height: 200px; border: blue 1px solid" >
                    index
                    <hr />
                    <router-view></router-view>
                    </div>`
        };
        const t2 = {
            template: `<div>t2</div>`
        };
        const t3 = {
            template: `<div>t3</div>`
        };

        // 2. 定义路由
        const my_router = new VueRouter({
           routes: [
               {
                   path: '/index',
                   component: t1,
                   children: [
                       {
                           path: "t2",
                           component: t2
                       },
                       {
                           path: "t3",
                           component: t3
                       }
                   ]
               },

           ]
        });
        // 3. 引用路由
        var vm = new Vue({
           el: '#app-28',
            router: my_router
        });
    </script>

</body>
</html>